﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SaleModiTpzk.aspx.vb" Inherits="Slxt.SaleModiTpzk" %>
<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title runat="server" id="titleName">特批折扣</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<link rel="stylesheet" type="text/css" href="/_nav/menu.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
		<link rel="stylesheet" type="text/css" href="/_grid/map_grid.css">
		<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">
		<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
		<link rel="stylesheet" type="text/css" href="/_nav/nav.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">
		<script language="javascript" src="/_controls/settings.aspx"></script>
		<script language="javascript" src="/_forms/FormBase.js"></script>
		<script language="javascript" src="/_controls/setting.js"></script>
		<script language="javascript" src="/_controls/util/util.js"></script>
		<script language="javascript" src="/_controls/datetime/date.js"></script>
		<script language="javascript" src="/_controls/datetime/time.js"></script>
		<script language="javascript" src="/_controls/number/number.js"></script>
		<script language="javascript" src="/_controls/lookup/map_lookup.js"></script>
		<script language="javascript" src="/_controls/lookup/map_lookupDialogs.js"></script>
		<script language="javascript" src="/_nav/menu.js"></script>
		<script language="javascript" src="/_common/scripts/global.js"></script>
		<script language="javascript" src="/PubProject/js/Public.js"></script>
		<!-- workflow -->
		<script language="javascript" src="/MyWorkflow/workflow.js"></script>
		<script language="javascript" src="/slxt/js/Public.js"></script>
		<script language="javascript" src="/slxt/xsxc/XsXc_XsChg.js"></script>	
		<script language="javascript">
		//在线帮助文件
		var _MyHelpfile = "/Slxt/help/topics/交易管理/定单管理/业务变更.html";
		var operHandler="";
		
	    // 初始化界面
		function window.onload() {
		    var strBgShConfig = Form1.txtBgShConfig.value;
		    
            //控制按钮显示
		    setRights();
		    
		    switch (__mode.value) {
		        case "1": //新增模式
		            HideShowElement("appForm_DjBldCjPrice", "text", "none");
		            HideShowElement("appForm_DjTnCjPrice", "text", "none");
		            HideShowElement("appForm_DjRoomTotal", "text", "none");

		            //根据优惠方式控制显示
		            chgOfferType_Load(appForm.appForm_OfferType.value);

		            break;
		        case "2": //编辑模式
		            HideShowElement("appForm_DjBldCjPrice", "text", "none");
		            HideShowElement("appForm_DjTnCjPrice", "text", "none");
		            HideShowElement("appForm_DjRoomTotal", "text", "none");
		            
		            chgOfferType_Load(appForm.appForm_OfferType.value);
		            break;
		        case "3":
		            HideShowElement("appForm_DjBldCjPrice", "text", "none");
		            HideShowElement("appForm_DjTnCjPrice", "text", "none");
		            HideShowElement("appForm_DjRoomTotal", "text", "none");
		            
		            deDisplay("btnOk");
		            document.all("btnCancel").innerText = "关 闭";
		            appForm.appForm_OfferDiscntValue.setReadOnly(true);
		            appForm.appForm_OfferPrice.setReadOnly(true);
		            break;
		    }
            //没有开启审批时
		    if (document.all.__isSp && document.all.__isSp.value == "0") {
		        trzc.style.display = "none";
		        trsp.style.display = "";
		        appForm._bSaving = true;
		        appForm.ApplyBy.value = txtUserName.value;
		        appForm.ApplyDate.value = txtToday.value;
		        appForm.appForm_IsApproved.parentElement.style.display = "none";
		        appForm.appForm_IsApproved.parentElement.previousSibling.style.display = "none";
		        appForm.Opinion.parentElement.parentElement.style.display = "none";
		        
		        SetControlReq(appForm.ApplyBy, true);
		        SetControlReq(appForm.ApplyDate, true);
		    }

		    // 按套计价时，使用总价基准计算折扣
		    var sCalStd;
		    if (Form1.txtCalStd.value == "1" || appForm.appForm_CalMode.value == "按套") {
		        sCalStd = "1";
		        document.getElementById("appForm_appForm_OfferType1").disabled = true;
		    }

		    chgColor();
		    
		    if (document.getElementById("txtIsjydjx").value == "0") {
		        HideShowElement("appForm_DjBldCjPrice", "text", "none");
		        HideShowElement("appForm_DjTnCjPrice", "text", "none");
		        HideShowElement("appForm_DjRoomTotal", "text", "none");
		    }
		};

		//切换优惠方式
		function chgOfferType(OfferType) {
		    var decPrice = appForm.appForm_OfferPrice.value.replace(/,/g, "");
		    var strCalMode = appForm.appForm_CalMode.value;
		    appForm.appForm_OfferPrice.setValue("0.00");
		    if (OfferType == "打折") {
		        appForm.appForm_OfferDiscntValue.setReadOnly(false);
		        appForm.appForm_OfferPrice.setReadOnly(true);
		        appForm.appForm_OfferPrice.value = "0.00";
		        appForm.appForm_OfferDiscntValue.value = "100.00";
		        SetControlReq(appForm.appForm_OfferDiscntValue, true);
		        SetControlReq(appForm.appForm_OfferPrice, false);
		    }
		    else {
		        appForm.appForm_OfferPrice.setReadOnly(false);
		        appForm.appForm_OfferDiscntValue.setReadOnly(true);
		        appForm.appForm_OfferDiscntValue.value = "0.00";
		        SetControlReq(appForm.appForm_OfferPrice, true);
		        SetControlReq(appForm.appForm_OfferDiscntValue, false);
		    }
		    if (OfferType == "指定单价") {
		        if (strCalMode == "按建筑面积" || strCalMode == "按套") {
		            appForm.appForm_OfferPrice.setValue(appForm.appForm_BldCjPrice.value);
		        }
		        else {
		            appForm.appForm_OfferPrice.setValue(appForm.appForm_TnCjPrice.value);
		        }

		    }
		    if (OfferType == "指定总价") {
		        appForm.appForm_OfferPrice.setValue(appForm.appForm_RoomTotal.value);
		    }
		    chgOfferValue(OfferType, "0.00");


		};
		function chgOfferType_Load(OfferType) {
		    var decPrice = appForm.appForm_OfferPrice.value.replace(/,/g, "");
		    var strCalMode = appForm.appForm_CalMode.value;
		    //appForm.appForm_OfferPrice.setValue("0.00");
		    if (OfferType == "打折") {
		        appForm.appForm_OfferDiscntValue.setReadOnly(false);
		        appForm.appForm_OfferPrice.setReadOnly(true);
		        appForm.appForm_OfferPrice.value = "0.00";
		        SetControlReq(appForm.appForm_OfferDiscntValue, true);
		        SetControlReq(appForm.appForm_OfferPrice, false);
		    }
		    else {
		        appForm.appForm_OfferPrice.setReadOnly(false);
		        appForm.appForm_OfferDiscntValue.setReadOnly(true);
		        appForm.appForm_OfferDiscntValue.value = "0.00";
		        SetControlReq(appForm.appForm_OfferPrice, true);
		        SetControlReq(appForm.appForm_OfferDiscntValue, false);
		    }
		    if (OfferType == "指定单价") {
		        if (strCalMode == "按建筑面积" || strCalMode == "按套") {
		            appForm.appForm_OfferPrice.setValue(appForm.appForm_newBldCjPrice.value);
		        }
		        else {
		            appForm.appForm_OfferPrice.setValue(appForm.appForm_newTnCjPrice.value);
		        }

		    }
		    if (OfferType == "指定总价") {
		        appForm.appForm_OfferPrice.setValue(appForm.appForm_newRoomTotal.value);
		    }
		    chgOfferValue(OfferType, "0.00");


		};
		function chgOfferTypeOnChgValue() {
		    var OfferType = appForm.appForm_OfferType.value;
		    var decPrice = appForm.appForm_OfferPrice.value.replace(/,/g, "");
		    if (decPrice <= 0 && OfferType == "指定单价") {
		        alert("指定单价不能小于等于0！");
		        event.srcElement.isBlur = true;
		        document.getElementById('appForm_OfferPrice').focus();

		        return;
		    }
		    if (decPrice <= 0 && OfferType == "指定总价") {
		        alert("指定总价不能小于等于0！");
		        event.srcElement.isBlur = true;
		        document.getElementById('appForm_OfferPrice').focus();
		        return;
		    }
		};
		//修改折扣，金额信息时，从新计算新的房价
		function chgOfferValue(OfferType, rtnValue) {
		    if (event.srcElement && event.srcElement.isBlur) {
		        event.srcElement.isBlur = undefined;
		        return;
		    }
		    appForm.appForm_DjBldCjPrice.style.color = "black";
		    appForm.appForm_DjTnCjPrice.style.color = "black";
		    appForm.appForm_DjRoomTotal.style.color = "black";
		    appForm.appForm_OfferDiscntValue.setValue(Round(appForm.appForm_OfferDiscntValue.value.replace(/,/g, ""), 2));
		    appForm.appForm_OfferPrice.setValue(Round(appForm.appForm_OfferPrice.value.replace(/,/g, ""), 2));

		    var strOfferType = "";
		    var decNewTotalPrice, decNewBldCjPrice, decNewTnCjPrice;
		    if (OfferType == "") {
		        strOfferType = appForm.appForm_OfferType.value;
		    }
		    else {
		        strOfferType = OfferType;
		    }

		    var strCalMode = appForm.appForm_CalMode.value;
		    var decRoomTotal = appForm.appForm_RoomTotal.value.replace(/,/g, "");
		    var decBldArea = appForm.appForm_BldArea.value.replace(/,/g, "");
		    var decTnArea = appForm.appForm_TnArea.value.replace(/,/g, "");
		    var decDiscnt = appForm.appForm_OfferDiscntValue.value.replace(/,/g, "");
		    var decPrice = appForm.appForm_OfferPrice.value.replace(/,/g, "");
		    var decBldPrice = appForm.appForm_BldCjPrice.value.replace(/,/g, "");
		    var decTnPrice = appForm.appForm_TnPrice.value.replace(/,/g, "");

		    if (strOfferType == "打折") {
		        if (appForm.appForm_OfferDiscntValue.value == "") {
		            decNewTotalPrice = appForm.appForm_RoomTotal.value;
		            decNewBldCjPrice = appForm.appForm_BldCjPrice.value;
		            decNewTnCjPrice = appForm.appForm_TnCjPrice.value;
		            appForm.appForm_newRoomTotal.setValue(decNewTotalPrice);
		            appForm.appForm_newTnCjPrice.setValue(decNewTnCjPrice);
		            appForm.appForm_newBldCjPrice.setValue(decNewBldCjPrice);
		            return;
		        }
		        if (parseFloat(appForm.appForm_OfferDiscntValue.value) >= 100 || parseFloat(appForm.appForm_OfferDiscntValue.value) < 0) {
		            decNewTotalPrice = appForm.appForm_RoomTotal.value;
		            decNewBldCjPrice = appForm.appForm_BldCjPrice.value;
		            decNewTnCjPrice = appForm.appForm_TnCjPrice.value;
		            appForm.appForm_newRoomTotal.setValue(decNewTotalPrice);
		            appForm.appForm_newTnCjPrice.setValue(decNewTnCjPrice);
		            appForm.appForm_newBldCjPrice.setValue(decNewBldCjPrice);
		            return;
		        }
		        //修改折扣信息时，从新计算房间成交总价，建筑单价，套内单价
		        decNewTotalPrice = Round(parseFloat(decRoomTotal) * parseFloat(decDiscnt) / 100, GetTotalZero());
		        decNewBldCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decBldArea), GetPriceZero());
		        decNewTnCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decTnArea), GetPriceZero());

		        appForm.appForm_newRoomTotal.setValue(decNewTotalPrice);
		        appForm.appForm_newTnCjPrice.setValue(decNewTnCjPrice);
		        appForm.appForm_newBldCjPrice.setValue(decNewBldCjPrice);
		    }
		    else {
		        if (appForm.appForm_OfferPrice.value == "") {
		            decNewTotalPrice = appForm.appForm_RoomTotal.value;
		            decNewBldCjPrice = appForm.appForm_BldCjPrice.value;
		            decNewTnCjPrice = appForm.appForm_TnCjPrice.value;
		            appForm.appForm_newRoomTotal.setValue(decNewTotalPrice);
		            appForm.appForm_newTnCjPrice.setValue(decNewTnCjPrice);
		            appForm.appForm_newBldCjPrice.setValue(decNewBldCjPrice);
		            return;
		        }
		        //修改金额信息时，从新计算房间成交总价，建筑单价，套内单价
		        switch (strOfferType) {
		            case "单价优惠":
		                if (decPrice == 0) {
		                    decNewTotalPrice = appForm.appForm_RoomTotal.value;
		                    decNewBldCjPrice = appForm.appForm_BldCjPrice.value;
		                    decNewTnCjPrice = appForm.appForm_TnCjPrice.value;
		                }
		                else {
		                    if (strCalMode == "按建筑面积" || strCalMode == "按套") {
		                        decNewBldCjPrice = Round(parseFloat(decRoomTotal) / parseFloat(decBldArea) - parseFloat(decPrice), GetPriceZero());
		                        decNewTotalPrice = Round(parseFloat(decNewBldCjPrice) * parseFloat(decBldArea), GetTotalZero());
		                        decNewTnCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decTnArea), GetPriceZero());
		                    }
		                    else {
		                        decNewTnCjPrice = Round(parseFloat(decRoomTotal) / parseFloat(decTnArea) - parseFloat(decPrice), GetPriceZero());
		                        decNewTotalPrice = Round(parseFloat(decNewTnCjPrice) * parseFloat(decTnArea), GetTotalZero());
		                        decNewBldCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decBldArea), GetPriceZero());
		                    }
		                }
		                break;
		            case "总价优惠":

		                if (decPrice == 0) {
		                    decNewTotalPrice = appForm.appForm_RoomTotal.value;
		                    decNewBldCjPrice = appForm.appForm_BldCjPrice.value;
		                    decNewTnCjPrice = appForm.appForm_TnCjPrice.value;
		                }
		                else {
		                    decNewTotalPrice = Round(parseFloat(decRoomTotal) - parseFloat(decPrice), GetTotalZero());
		                    decNewTnCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decTnArea), GetPriceZero());
		                    decNewBldCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decBldArea), GetPriceZero());
		                }
		                break;
		            case "指定单价":
		                if (strCalMode == "按建筑面积" || strCalMode == "按套") {
		                    decNewBldCjPrice = Round(parseFloat(decPrice), GetPriceZero());
		                    decNewTotalPrice = Round(parseFloat(decNewBldCjPrice) * parseFloat(decBldArea), GetTotalZero());
		                    decNewTnCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decTnArea), GetPriceZero());
		                }
		                else {
		                    decNewTnCjPrice = Round(parseFloat(decPrice), GetPriceZero());
		                    decNewTotalPrice = Round(parseFloat(decNewTnCjPrice) * parseFloat(decTnArea), GetTotalZero());
		                    decNewBldCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decBldArea), GetPriceZero());
		                }
		                break;
		            case "指定总价":
		                decNewTotalPrice = Round(parseFloat(decPrice), GetTotalZero());
		                decNewTnCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decTnArea), GetPriceZero());
		                decNewBldCjPrice = Round(parseFloat(decNewTotalPrice) / parseFloat(decBldArea), GetPriceZero());
		                break;
		        }

		        if (parseFloat(decNewTotalPrice) <= 0 && OfferType == "") {
		            alert("新成交房间总价不能小于等于0，请重新定价！");
		            document.getElementById('appForm_OfferPrice').focus();
		            event.returnValue = false;
		            appForm.appForm_OfferPrice.setValue(rtnValue);
		            return;
		        }
		        else if (parseFloat(decNewTotalPrice) <= 0) {
		            alert("新成交房间总价不能小于等于0，请重新定价！");
		            document.getElementById('appForm_OfferPrice').focus();
		            event.returnValue = false;
		            appForm.appForm_OfferPrice.setValue(rtnValue);
		            return;
		        }
		        else if (Round(parseFloat(decNewTotalPrice), 2) > 100000000) {
		            alert("数值超界！");
		            event.returnValue = false;
		            appForm.appForm_OfferPrice.setValue(rtnValue);
		            document.getElementById('appForm_OfferPrice').focus();
		            return;
		        }
		        else {
		            appForm.appForm_newRoomTotal.setValue(decNewTotalPrice);
		            appForm.appForm_newTnCjPrice.setValue(decNewTnCjPrice);
		            appForm.appForm_newBldCjPrice.setValue(decNewBldCjPrice);
		        }
		    }
		};

		function chgColor() {
		    //将新计算的价格和底价进行比较，如果大于于，则将底价显示为红色
		    if (parseFloat(parseFloat(appForm.appForm_newBldCjPrice.value.replace(/,/g, ""))) < parseFloat(appForm.appForm_DjBldCjPrice.value.replace(/,/g, ""))) {
		        appForm.appForm_DjBldCjPrice.style.color = "red";
		    }
		    if (parseFloat(parseFloat(appForm.appForm_newTnCjPrice.value.replace(/,/g, ""))) < parseFloat(appForm.appForm_DjTnCjPrice.value.replace(/,/g, ""))) {
		        appForm.appForm_DjTnCjPrice.style.color = "red";
		    }
		    if (parseFloat(parseFloat(appForm.appForm_newRoomTotal.value.replace(/,/g, ""))) < parseFloat(appForm.appForm_DjRoomTotal.value.replace(/,/g, ""))) {
		        appForm.appForm_DjRoomTotal.style.color = "red";
		    }
		}
		
        //获取单价保留位
		function GetPriceZero() {
		    if (Form1.txtPriceZero.value == "") { return 2 }
		    else { return parseInt(Form1.txtPriceZero.value); }
		}
        //获取总价保留位
		function GetTotalZero() {
		    if (Form1.txtTotalZero.value == "") { return 2 }
		    else { return parseInt(Form1.txtTotalZero.value); }
		}
		//打开客户链接
		function OpenSaleModiApplyCustomer(CstGUID) {
		    event.returnValue = false;
		    if (document.all.__showmodel && document.all.__showmodel.value == "0") {
		        parent.dialogArguments.OpenCustomer("3", CstGUID, "01010203");
		        return;
		    }
		    OpenCustomer("3", CstGUID, "01010203");
		}

		//打开房间链接
		function OpenSaleModiApplyRoom(RoomGUID) {
		    event.returnValue = false;
		    if (document.all.__showmodel && document.all.__showmodel.value == "0") {
		        parent.dialogArguments.OpenRoomList("3", RoomGUID, '01010105');
		        return;
		    }

		    OpenRoomList("3", RoomGUID, '01010105');
		}

		//打开定单合同查询窗口
		function OpenOrderContract(sSaleGUID) {
		    event.returnValue = false;

		    var sSaleTyep = appForm.SaleType.value;
		    if (sSaleTyep == "定单") sSaleTyep = '小订';
		    if (document.all.__showmodel && document.all.__showmodel.value == "0") {
		        parent.dialogArguments.openModiOrderContractWin(appForm.ProjGUID.value, sSaleGUID, sSaleTyep, 3);
		        return;
		    }
		    openModiOrderContractWin(appForm.ProjGUID.value, sSaleGUID, sSaleTyep, 3)
		}

		//打开项目窗口
		function OpenProject(sProjGUID) {
		    event.returnValue = false;
		    var sPath = "/PubProject/Project/Project_Form.aspx?mode=3&oid=" + escape(sProjGUID) + "&funcid=" + escape("01010102") + "&isshare=0&IfEnd=1";
		    var iX = 800;
		    var iY = 600;
		    OpenWin(sPath, iX, iY, 0);
		}
		
		//校验必填项
		function validReq() {
		    if (appForm.appForm_OfferType.value == "打折") {
		        if (appForm.appForm_OfferDiscntValue.value == "0.00" || appForm.appForm_OfferDiscntValue.value == "100.00") {
		            alert("所填折扣值必须大于0，小于100！");
		            return false;
		        }
		    }
		    if (appForm.appForm_OfferType.value == "单价优惠" || appForm.appForm_OfferType.value == "总价优惠") {
		        if (parseFloat(appForm.appForm_OfferPrice.value.replace(/,/g, "")) <= 0) {
		            alert("优惠金额必须大于0！");
		            appForm.appForm_OfferPrice.focus();
		            appForm.appForm_OfferPrice.select();
		            return false;
		        }
		    }
		    if (appForm.appForm_OfferType.value == "指定单价") {
		        if (appForm.appForm_CalMode.value == "按建筑面积" || appForm.appForm_CalMode.value == "按套") {
		            if (parseFloat(appForm.appForm_OfferPrice.value.replace(/,/g, "")) >= parseFloat(appForm.appForm_BldCjPrice.value.replace(/,/g, ""))) {
		                alert("指定单价必须小于原成交单价！");
		                appForm.appForm_OfferPrice.focus();
		                appForm.appForm_OfferPrice.select();
		                return false;
		            }
		        }
		        else {
		            if (parseFloat(appForm.appForm_OfferPrice.value.replace(/,/g, "")) >= parseFloat(appForm.appForm_TnCjPrice.value.replace(/,/g, ""))) {
		                alert("指定单价必须小于原成交单价！");
		                appForm.appForm_OfferPrice.focus();
		                appForm.appForm_OfferPrice.select();
		                return false;
		            }
		        }
		    }
		    if (appForm.appForm_OfferType.value == "指定总价") {
		        if (parseFloat(appForm.appForm_OfferPrice.value.replace(/,/g, "")) >= parseFloat(appForm.appForm_RoomTotal.value.replace(/,/g, ""))) {
		            alert("指定总价必须小于原成交总价！");
		            appForm.appForm_OfferPrice.focus();
		            appForm.appForm_OfferPrice.select();
		            return false;
		        }
		    }
		    if (parseInt(appForm.appForm_newRoomTotal.value) <= 0) {
		        alert("新成交房间总价不能小于等于0，请重新定价！");
		        document.getElementById('appForm_OfferPrice').focus();
		        return false;
		    }
		}

		function CheckApplyDate() {
		    var dtywbldate = StringToDate(appForm.appForm_ywbldate.value);
		    var dtApplyDate = StringToDate(appForm.ApplyDate.value);
		    if (dtApplyDate < dtywbldate) {
		        alert("经办日期必须大于等于业务归属日期！");
		        return false;
		    }
		    return true;
		}

	    //对象焦点失去前的校验，用于解决目前平台控件校验只能在onblur时造成的多控件争焦点的情况
	    function BeforeDeActivateForTxt(obj)
	    {
	   	    if ( obj.maxLength != null && GetLen(obj.value) > obj.maxLength )
	        {
		        alert("录入字符不允许超过" + obj.maxLength.toString() + "字节！");
		        obj.select();
		        event.returnValue=false;
		        return false;
	        }

            if(GetLen(obj.value)==0)
            {
               event.returnValue=true;
		       return true;            
            }
	        //校验文本框中的字符串中是否有不允许录入的字符
	        var BlValidatePass=validateChars(obj);
	        
	         event.returnValue=BlValidatePass;
		     return BlValidatePass;
        }

        function validateChars(obj) {
            var i;

            if (obj.forbiddenChars != "") {
                //检查是否有禁止录入的字符
                for (i = 0; i < obj.forbiddenChars.length; i++) {
                    if (obj.value.indexOf(obj.forbiddenChars.charAt(i)) >= 0) {
                        alert("不允许录入特殊字符：\n\n\t" + obj.forbiddenChars.split("").join(", "));
                        obj.select();
                        return false;
                    }
                }
            }
            else if (obj.allowChars != "") {
                //如果没有指定禁止录入的字符，检查字符是否在允许字符串中
                for (i = 0; i < obj.value.length; i++) {
                    if (obj.allowChars.indexOf(obj.value.charAt(i)) < 0) {
                        alert("只允许录入以下字符：\n\n\t" + obj.allowChars.split("").join(", "));
                        obj.select();
                        return false;
                    }
                }
            }

            return true;
        }
	    
	     //对象焦点失去前的校验，用于解决目前平台控件校验只能在onblur时造成的多控件争焦点的情况
        function BeforeDeActivateForNum(obj) {
            //设置面积保留位
            //史海峰	2005-01-07
            if (obj.acc == "mj") {
                obj.acc = 4;
            }
            if (isNaN(obj.acc))			// 自定义小数位数
            {
                obj.acc = eval("FMT_" + obj.acc);
            }
            //
            var sValue = Trim(obj.value);
            var iMinValue = parseFloat(obj.min);
            var iMaxValue = parseFloat(obj.max);
            var bGrouping = (obj.grp == "true"); 		//是否带千分号

            var sFormat = ORG_NUMBER_FORMAT;
            var iAccuracy = parseInt(obj.acc, 10);

            var oEvent;

            if (sValue.length == 0) {
                event.returnValue = true;
                return true;
            }

            if (obj.dt == "integer") {
                sValue = FormatInteger(sValue, iMinValue, iMaxValue, bGrouping, sFormat);

                if (sValue) {
                    event.returnValue = true;
                    return true;
                }
                else {
                    obj.select();
                    event.returnValue = false;
                    return false;
                }
            }
            else {
                sValue = FormatFloat(sValue, iMinValue, iMaxValue, bGrouping, sFormat, iAccuracy);

                if (sValue) {
                    event.returnValue = true;
                    return true;
                }
                else {
                    obj.select();
                    event.returnValue = false;
                    return false;
                }
            }

            if (!obj.returnValue) {
                obj.select();
                event.returnValue = false;
                return false;
            }

            event.returnValue = true;
            return true;
        }

        //点击确定按钮
        function Ok() {
            //保存前的校验
            if (validReq() == false) return;
            if (appForm.IsValid() == false) return; 
            var strDataXml = "";

            strDataXml = "<s_SaleModiLog keyname=\"SaleModiLogGUID\" keyvalue=\"\">";
            strDataXml += "<BUGUID>" + appForm.BUGUID.value + "</BUGUID>";
            strDataXml += "<ProjGUID>" + appForm.ProjGUID.value + "</ProjGUID>";
            strDataXml += "<ForeSaleGUID>" + appForm.SaleGUID.value + "</ForeSaleGUID>";
            strDataXml += "<ForeSaleType>" + appForm.SaleType.value + "</ForeSaleType>";
            strDataXml += "<ApplyType>" + appForm.ApplyType.value + "</ApplyType>";
            strDataXml += "<PastObligee>" + appForm.CstName.value + "</PastObligee>";
            strDataXml += "<PastObligeeGUID>" + appForm.CstGUID.value + "</PastObligeeGUID>";
            strDataXml += "<PastRoomGUID>" + appForm.RoomGUID.value + "</PastRoomGUID>";
            strDataXml += "<NowObligee></NowObligee>";
            strDataXml += "<NowObligeeGUID></NowObligeeGUID>";
            strDataXml += "<NowRoomGUID></NowRoomGUID>";
            strDataXml += "<BackSaleGUID></BackSaleGUID>";
            strDataXml += "<BackSaleType></BackSaleType>";
            strDataXml += "<ForeTradeGUID>" + appForm.appForm_TradeGUID.value + "</ForeTradeGUID>";
            strDataXml += "<Pay>" + appForm.Pay.value.replace(/,/ig, "") + "</Pay>";
            strDataXml += "<Refundment>0</Refundment>";
            strDataXml += "<ReasonSort>" + appForm.ReasonSort.value + "</ReasonSort>";
            strDataXml += "<Reason>" + appForm.Reason.value + "</Reason>";
            strDataXml += "<HandCharge>" + appForm.HandCharge.value.replace(/,/ig, "") + "</HandCharge>";
            strDataXml += "<ApproveBy>" + appForm.ApproveBy.value + "</ApproveBy>";
            strDataXml += "<ApproveDate>" + appForm.ApproveDate.value + "</ApproveDate>";
            strDataXml += "<ApplyBy>" + appForm.ApplyBy.value + "</ApplyBy>";
            strDataXml += "<ApplyDate>" + appForm.ApplyDate.value + "</ApplyDate>";
            strDataXml += "</s_SaleModiLog>";

           
            event.returnValue = false;
            appForm._bAlert = false;
            appForm._bSaving = true;

            var strDataXML_fsp = getTpzkModiApplyXml_fsp();
            strDataXML_fsp = "<xml>" + strDataXML_fsp + "</xml>";
            var sFile = "/slxt/XSXC/XSXC_XMLHTTP.aspx";
            var strRtn = openXMLHTTP(sFile, "SaveTpzkModiInfo", strDataXML_fsp);

            if (strRtn.indexOf("OK") != -1) {
                parent.returnValue = strDataXml + "|" + strRtn.split("|")[1];
                parent.window.close();
                this.close();
            }
            else {
                alert("保存失败，请联系管理员！");
                return false;
            }
        }
		</script>
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<table class="layout" cellSpacing="0" cellPadding="0">
			<COLGROUP>
				<col width="140"> <!-- 导航菜单：140px -->
				<col>
			</COLGROUP>
			<tr height="48" id="trzc">
				<td colSpan="2">
					<input id="txtUserName" type="text" style="DISPLAY:none" runat="server"> <input id="txtToday" type="text" style="DISPLAY:none" runat="server">
					<!-- 菜单 --><mnu:appformmenu id="appFormMenu" runat="server"></mnu:appformmenu></td>
			</tr>
			<tr>
				<td colSpan="2">
					<div class="area">
						<cnt:AppForm id="appForm" runat="server" DefaultValueXml="" processtype="xmlhttp" onbeforesave="oprBeforeSave()" onaftersave="oprAfterSave()"></cnt:AppForm>
					</div>
				</td>
			</tr>
			<tr height="40"  id="trsp"  style="display:none">
					<td class="buttons" colSpan="2">
						<button onclick="Ok()" id="btnOk" type="button">确 定</button>&nbsp;&nbsp; <button onclick="parent.window.close();"  id="btnCancel"  type="button">
							取 消</button>
					</td>
				</tr>
		</table>
			<form id="Form1" runat="server">
			<input id="txtWorkFlowGuid" type="text" style="DISPLAY:none">
			<!-- 业务参数  -->
			<asp:textbox id="txtBgShConfig" style="DISPLAY: none" Runat="server"></asp:textbox><!--变更审批业务参数设置值-->
			<asp:textbox id="txtPriceZero" style="DISPLAY: none" Runat="server"></asp:textbox>
			<asp:textbox id="txtTotalZero" style="DISPLAY: none" Runat="server"></asp:textbox>
			<asp:textbox id="txtApprovePower" style="DISPLAY: none" Runat="server"></asp:textbox>
			<asp:textbox id="txtCalStd" style="DISPLAY: none" Runat="server"></asp:textbox>
			<asp:textbox id="txtIsjydjx" style="DISPLAY: none" Runat="server"></asp:textbox>
			</form>
	</body>
</HTML>
